load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

# A set of types and utilities for working with compacted trace data sets, such
# as those produced by ../traceparser.
licenses(["notice"])  # Apache License 2.0

go_library(
    name = "trace",
    importpath = "github.com/google/schedviz/tracedata/trace",

    srcs = ["trace_event.go"],
    visibility = ["//visibility:public"],
    deps = [
        ":schedviz_events_go_proto",
        "@org_golang_google_grpc//codes:go_default_library",
        "@org_golang_google_grpc//status:go_default_library",
    ],
)

go_test(
    name = "trace_test",
    size = "small",
    srcs = ["trace_event_test.go"],
    embed = [":trace"],
    deps = [
        ":eventsetbuilder",
        ":schedviz_events_go_proto",
        ":testeventsetbuilder",
    ],
)

go_library(
    name = "eventsetbuilder",
    importpath = "github.com/google/schedviz/tracedata/eventsetbuilder",

    srcs = ["event_set_builder.go"],
    visibility = ["//visibility:public"],
    deps = [
        ":schedviz_events_go_proto",
        "//analysis:event_loaders_go_proto",
        "//traceparser",
    ],
)

go_test(
    name = "eventsetbuilder_test",
    size = "small",
    srcs = ["event_set_builder_test.go"],
    embed = [":eventsetbuilder"],
    deps = [
        ":schedviz_events_go_proto",
        "//testhelpers",
    ],
)

proto_library(
    name = "schedviz_events_proto",
    srcs = ["events.proto"],
    visibility = ["//visibility:public"],
    deps = [
        "//analysis:event_loaders_proto",
        "@com_google_protobuf//:timestamp_proto",
    ],
)

go_proto_library(
    name = "schedviz_events_go_proto",
    importpath = "github.com/google/schedviz/tracedata/schedviz_events_go_proto",

    proto = ":schedviz_events_proto",
    visibility = ["//visibility:public"],
    deps = ["//analysis:event_loaders_go_proto"],
)

go_library(
    name = "testeventsetbuilder",
    importpath = "github.com/google/schedviz/tracedata/testeventsetbuilder",

    testonly = True,
    srcs = ["test_event_set_builder.go"],
    visibility = ["//visibility:public"],
    deps = [
        ":eventsetbuilder",
        ":schedviz_events_go_proto",
    ],
)

go_library(
    name = "schedevent",
    importpath = "github.com/google/schedviz/tracedata/schedevent",

    srcs = ["sched_event.go"],
    visibility = ["//visibility:public"],
    deps = [":trace"],
)

go_library(
    name = "clipping",
    importpath = "github.com/google/schedviz/tracedata/clipping",

    srcs = ["clipping.go"],
    visibility = ["//visibility:public"],
    deps = [":schedviz_events_go_proto"],
)

go_test(
    name = "clipping_test",
    size = "small",
    srcs = ["clipping_test.go"],
    embed = [":clipping"],
    deps = [
        ":schedviz_events_go_proto",
    ],
)
